package org.easy.tool.controller;

import org.easy.tool.common.R;
import org.easy.tool.entity.Problem;
import org.easy.tool.service.IProblem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *  Problem模块
 * @author Valley
 * @since 2023-08-25 14:20:43
 */
@RestController
@RequestMapping("/problem")
@CrossOrigin
public class ProblemController {

    @Autowired
    IProblem problemService;

    /**
     * 功能：提交问题
     */
    @PostMapping("submitProblem")
    public R submitProblem(@RequestBody Problem problem) throws Exception {
        String problemId = problemService.addProblem(problem);
        return R.ok(problemId);
    }

    /**
     * 功能：获取问题
     */
    @RequestMapping("getProblemById")
    public R getProblemByUser(String id) throws Exception {
        Problem problem = problemService.getProblemById(id);
        return R.ok(problem);
    }

}
